import Vue from 'vue'
import Vuex from 'vuex'
import api from '@/assets/config/api.js'
Vue.use(Vuex)

import axios from 'axios'

export default new Vuex.Store({
  state: {
    cartTotal:{
      checkedGoodsAmount: 0,
      checkedGoodsCount: 0,
      goodsAmount: 0,
      goodsCount: 0
    },
    cartList:{}

  },
  mutations: {
    setCartTotal(state,carttotal){
      state.cartTotal = carttotal
    },
    setCartList(state,cartlist){
      state.cartList = cartlist
    }
  },
  actions: {
    AjaxCart: async function(content){
      let res = await axios.get(api.CartList)
      console.log(res)
      content.commit('setCartTotal',res.data.data.cartTotal)
      content.commit('setCartList',res.data.data.cartList)
    }
  },
  modules: {
  }
})
